
<input type="hidden" id="order_id" value="$order.id" />
<div class="row">
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">订单号:$order.order_nbr</h3>

            </div>
            <div class="panel-body form-inline">
                <table id="mainTable" class="table table-striped table-hover">
                    <tr>
                        <th>商品</th>

                        <th>单价</th>

                        <th>数量</th>

                        <th>实际支付</th>

                        <th>状态</th>

                        <th>操作</th>
                    </tr>

                    <tr>
                        <td>
                            <img src="$offer.img_url" width="200" height="150"/>
                            <p> $offer.offer_name</p>

                        </td>

                        <td>$offer.offer_price</td>

                        <td>$order.offer_num</td>

                        <td>$order.total_fee</td>

                        <td>
                            #if($order.status==-1)
                            已删除
                            #elseif($order.status==1)
                            待支付
                            #elseif($order.status==2)
                            待发货
                            #elseif($order.status==3)
                            待收货
                            #elseif($order.status==4)
                            待评价
                            #elseif($order.status==5)
                            已完成
                            #elseif($order.status==6)
                            退款中
                            #elseif($order.status==7)
                            已退款
                            #elseif($order.status==0)
                            已取消

                            #end

                        </td>

                        <td>
                            #if($order.status==2)
                            <button type="button"  onclick="fahuo($order.id)" style="margin-right: 5px;" class="btn btn-sm btn-danger btn-trans">发货</button>
                            #end
                        </td>

                    </tr>


                </table>
            </div>
        </div>
    </div>

                <div class="col-md-12">
                    <div class="panel panel-default">

                <div class="panel-body form-inline">
                <div  class="form-group col-sm-12" style="margin-top: 10px;">
                    <label class="col-sm-3 control-label">订单号：</label>
                    <div class="col-sm-6">

                        $order.order_nbr

                    </div>
                </div>
                <div  class="form-group col-sm-12" style="margin-top: 10px;">
                    <label class="col-sm-3 control-label">下单时间：</label>
                    <div class="col-sm-6">

                        $order.create_time

                    </div>
                </div>

                <div  class="form-group col-sm-12" style="margin-top: 10px;">
                    <label class="col-sm-3 control-label">下单用户昵称：</label>
                    <div class="col-sm-6">

                        $user.nick_name

                    </div>
                </div>

                <div  class="form-group col-sm-12" style="margin-top: 10px;">
                    <label class="col-sm-3 control-label">下单用户手机号：</label>
                    <div class="col-sm-6">

                        $user.phone

                    </div>
                </div>

                <div  class="form-group col-sm-12" style="margin-top: 10px;">
                    <label class="col-sm-3 control-label">下单用户ID：</label>
                    <div class="col-sm-6">

                        $user.login_account

                    </div>
                </div>

                <div class="form-group col-sm-12 " style="margin-top: 10px;">
                    <label class="col-sm-3 control-label">收货地址：</label>
                    <div class="col-sm-6">

                        $address.province $address.city $address.area $address.detail , $address.receiver ,$address.phone

                    </div>
                </div>


                <div  class="form-group col-sm-12" style="margin-top: 10px;">
                    <label class="col-sm-3 control-label">订单备注：</label>
                    <div class="col-sm-7">

                       <textarea id="order_desc" style="width: 600px;height: 200px;">$order.remark</textarea>

                    </div>
                </div>

            </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-primary" onclick="saveDesc();">保存备注</button>
                            <button type="button" class="btn btn-primary" onclick="gobackuser();">返回</button>
                        </div>
        </div>
    </div>
</div>

<div id="staffDialog" class="staff-dialog" style="display: none;">
    <div class="col-md-6" id="login-wrapper">
        <div class="panel panel-primary animated flipInY">
            <div class="panel-heading">
                <h3 class="panel-title">发货</h3>
                <div class="actions pull-right">
                    <i id="staffDialogClose" class="fa fa-times"></i>
                </div>
            </div>
            <div class="panel-body form-horizontal">

                <div class="form-group" >
                    <div class="col-md-3">发货快递：</div>
                    <div class="col-md-9">
                        <select  id="express_id" class="form-control"></select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-3">快递单号：</div>
                    <div class="col-md-9">
                        <input type="text"  class="form-control" id="express_num" placeholder="">
                    </div>
                </div>

                <div class="form-group">
                    <!--<div class="col-md-5">-->
                    <!--</div>-->
                    <div class="col-md-12">
                        <button onclick="saveExpress();" class="btn " >发货</button>

                    </div>
                </div>

            </div>
        </div>
    </div>
</div>

<script>

    var $staffDialog =$("#staffDialog");

    function gobackuser() {
        $('#main-content').load('/newshop/order/order/order.html');
    }
    
    function saveDesc() {
        var param={
            id: $("#order_id").val(),
            remark: $("#order_desc").val()

        }
        Ajax.ajax({
            url: "/order/update",
            data: param,
            type: "POST",
            dataType: 'json',
            success: function (res) {
                if (res.resultCode == 0) {
                    alert("操作成功");
                } else {
                    alert("操作失败");
                }
            },
            error: function(){
                alert("操作失败");
            }
        });
    }
    function fahuo(id){//,\'3\'


        $("#express_id").val("");
        $("#express_num").val("");

        $staffDialog.attr("order_id",id);

        $staffDialog.show();

    }


    function saveExpress(){
        var express_id = $("#express_id").val();
        var express_num = $("#express_num").val();
        debugger;
        if(express_id==""){
            alert("请选择快递");
            return;
        }
        if(express_num ==""){
            alert("请输入快递编号");
            return;
        }
        debugger;
        var param = {
            id:$staffDialog.attr("order_id"),
            express_id:express_id,
            express_num:express_num
        }
        Ajax.ajax({
            url: "/order/saveExpress",
            data: param,
            type: "POST",
            dataType: 'json',
            success: function (res) {
                debugger;
                alert(res.data);
                $staffDialog.hide();
                $('#main-content').load('/order/getOrderDetail?id='+$order.id);
            },
            error: function(){
                alert("操作失败");
            }
        });
    }

    $(function () {
        Ajax.ajax({
            url: "/order/queryExpress",

            type: "POST",
            dataType: 'json',
            success: function (res) {
                for(var i=0;i<res.length;i++){
                    var option=$("<option value='"+res[i].id+"'>"+res[i].name+"</option>");
                    $("#express_id").append(option);
                }
            },
            error: function(){
                alert("操作失败");
            }
        });

        //关闭窗口
        $('#staffDialogClose').on('click',function(){

            $staffDialog.hide();
        });
    });
</script>